/*
 * @ author madman 
 * @ use 文章schema
 */
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var shortid = require('shortid');
var goodsSchema = new Schema({
    // 文章ID
     _id: {
        type: String,
        'default': shortid.generate
    },
    // 文章标题
    title: {
        type: String,
        required: true
    },
    // 文章描述
    describe: {
    	type: String
    },
    // 商品缩略图
    thumbnail: {
        type: String,
    },
    // 文章缩组图
    thumbId: {
        type: String,
        ref: 'j_upload'
    },
    // 编辑器里的图片
    goodsThumbId: {
        type: String,
        ref: 'j_upload'
    },
    //密码访问
    password: {
        type: String
    },
    // 文章分类
    category: {
        type: String,
        ref: 'j_category',
        required: true
    },
    // 分类数组，存分类ID
    categoryArr: {
        type: Array,
        required: true
    },
    // 商品详情
    content: {
        type: String,
        required: true
    },
    // 存放草稿
    isRecycle: {
        type: Number,
        default: 0
    },
    // 推荐到首页显示
    isIndex: {
        type: Boolean,
        default: false
    },
    isSelves: {
    	type: Boolean,
        default: false
    },
    // 热门
    isHot: {
        type: Boolean,
        default: false
    },
    // 新建时间
    createdAt: {
        type: Date,
        default: Date.now
    },
    // 更新时间
    updataAt: {
        type: Date
    }
});
module.exports = mongoose.model('j_article', goodsSchema, 'j_article');